//
//  ForgotPasswordViewController.m
//  1gene
//
//  Created by 1jiyin on 16/3/3.
//  Copyright © 2016年 1jiyin. All rights reserved.
//
//***************************忘记密码***************************
#import "ForgotPasswordViewController.h"

@interface ForgotPasswordViewController ()<UITextFieldDelegate>
@property(nonatomic,copy)NSArray *dataArray;
@property(nonatomic,copy)UIView *backgroundView;//背景
@property(nonatomic,copy)UIImageView *manImgView;
@property(nonatomic,copy)UIImageView *womanImgView;
@property(nonatomic,assign)NSInteger sexSelected;//1男，2女，默认是1
@property(nonatomic,assign)NSInteger protocolSelected;///0未选中  1选中,默认是0
@property(nonatomic,copy)NSTimer *myTimer;
@property(nonatomic,copy)UIButton *getCodeBtn;//获取验证码
@property(nonatomic,assign)int myTime;

@property(nonatomic,assign)CGFloat man_y;
@property(nonatomic,assign)CGFloat woman_y;
@property(nonatomic,copy)UIButton *manBtn;
@property(nonatomic,copy)UIButton *womanBtn;


@property(nonatomic,copy)NSString *telephoneCode;

@property(nonatomic,copy)NSString *healthCode;

@property(nonatomic,copy)UITextField *userNewPasswordTextField;

@property(nonatomic,copy)UITextField *codeTextField;

@property(nonatomic,copy)UIButton *sureBtn;

@property(nonatomic,copy)UITextField *oldPhoneText;

@end

@implementation ForgotPasswordViewController
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor=[UIColor whiteColor];
    [self.view addSubview:[UIView new]];
    _myTime=60;
    [self initData];
    [self createNavigationController];
    [self createUI];
    // Do any additional setup after loading the view.
}
-(void)initData
{
    _dataArray=@[@{@"name":@"手机号码",@"image":@"telephone.png",@"placehoder":@"请输入手机号码"},@{@"name":@"验证码",@"image":@"code.png",@"placehoder":@"请输入验证码"},@{@"name":@"新密码",@"image":@"password-3-2.png",@"placehoder":@"请输入新的密码"}];
}
-(void)createNavigationController
{
     self.navigationController.navigationBar.barStyle=UIBarStyleBlack;
    //返回按钮
    UIButton *backBtn=[UIButton buttonWithType:UIButtonTypeCustom];
    backBtn.frame=CGRectMake(0, 0, 25, 25);
    [backBtn setBackgroundImage:[UIImage imageNamed:@"left_back"] forState:UIControlStateNormal];
    [backBtn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
    self.navigationItem.leftBarButtonItem=[[UIBarButtonItem alloc]initWithCustomView:backBtn];
    
    //标题
    UILabel *lab=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 100, 44)];
    lab.text=@"忘记密码";
    lab.textColor=[UIColor whiteColor];
    lab.font=[UIFont fontWithName:@"Arial-BoldMT" size:22 * kAdjustParamater];
    lab.textAlignment=NSTextAlignmentCenter;
    self.navigationItem.titleView=lab;
    self.navigationController.navigationBar.barTintColor=[UIColor colorWithRed:84/255.0 green:199/255.0 blue:222/255.0 alpha:1];
}
#pragma mark 返回上一页
-(void)btnClick:(UIButton *)sender
{
    
    if (_hideNavigationBar) {
        self.navigationController.navigationBar.hidden=YES;
    }else{
        self.navigationController.navigationBar.hidden=NO;
    }
    [self.navigationController popViewControllerAnimated:YES];
}
-(void)createUI
{
    UIScrollView *scrollView=[[UIScrollView alloc]initWithFrame:CGRectMake(0, 20+44, self.view.frame.size.width, self.view.frame.size.height-20-44)];
    scrollView.showsHorizontalScrollIndicator=NO;
    scrollView.showsVerticalScrollIndicator=NO;
    scrollView.contentSize=CGSizeMake(scrollView.frame.size.width, scrollView.frame.size.height*1.25);
    [self.view addSubview:scrollView];
    
    
    _backgroundView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height-20-44)];
    _backgroundView.userInteractionEnabled = YES;
    [scrollView addSubview:_backgroundView];
    CGFloat btn_w=self.view.frame.size.width-30*2;
    CGFloat btn_h=40;
#warning 张国文写的，添加手势
    // 为背景添加手势
    UITapGestureRecognizer *backGroundTapGes = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(cancelEditing:)];
    [_backgroundView addGestureRecognizer:backGroundTapGes];
    
    for (int i=0; i<_dataArray.count; i++) {
        //手机号码
        UILabel *phoneLab=[[UILabel alloc]initWithFrame:CGRectMake(30, 5+(btn_h*2+5)*i, btn_w, btn_h)];
        phoneLab.text=_dataArray[i][@"name"];
        phoneLab.font=[UIFont systemFontOfSize:16];
        phoneLab.textColor=[UIColor blackColor];
        [_backgroundView addSubview:phoneLab];
        
        UITextField *phoneTextField=[[UITextField alloc]initWithFrame:CGRectMake(phoneLab.frame.origin.x, CGRectGetMaxY(phoneLab.frame), btn_w, btn_h)];
        //        phoneTextField.delegate=self;
        phoneTextField.backgroundColor=[UIColor whiteColor];
        phoneTextField.font=[UIFont systemFontOfSize:15 * kAdjustParamater];
        phoneTextField.tintColor = kCyanColor;
        phoneTextField.delegate = self;
        
        UIView *phoneView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 54, btn_h)];
        //phoneView.backgroundColor=[UIColor colorWithRed:146/255.0 green:208/255.0 blue:234/255.0 alpha:1];
        
        UIView *backgroundView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, phoneView.frame.size.width-5, phoneView.frame.size.height)];
        backgroundView.backgroundColor=[UIColor colorWithRed:146/255.0 green:208/255.0 blue:234/255.0 alpha:1];
        [phoneView addSubview:backgroundView];
        
        
        UIImageView *phoneImgView=[[UIImageView alloc]initWithFrame:CGRectMake(10, 4, 30, btn_h-2*2-4)];
        UIImage *phoneImg=[UIImage imageNamed:_dataArray[i][@"image"]];
        phoneImg=[phoneImg imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        phoneImgView.image=phoneImg;
        
        [phoneView addSubview:phoneImgView];
        phoneTextField.tag=100+i;
        phoneTextField.leftView=phoneView;
        phoneTextField.leftViewMode=UITextFieldViewModeAlways;
        phoneTextField.clearButtonMode=UITextFieldViewModeWhileEditing;
        
        phoneTextField.placeholder=_dataArray[i][@"placehoder"];
        phoneTextField.backgroundColor=[UIColor whiteColor];
        phoneTextField.layer.borderColor=[UIColor colorWithRed:146/255.0 green:208/255.0 blue:234/255.0 alpha:1].CGColor;
        phoneTextField.layer.cornerRadius=5.0;
        phoneTextField.layer.borderWidth=1.0;
        [_backgroundView addSubview:phoneTextField];
        if (i==1) {
            UIView *codeBackgroundView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 70, btn_h)];
            UIButton *getCodeBtn=[UIButton buttonWithType:UIButtonTypeCustom];
            getCodeBtn.backgroundColor=[UIColor colorWithRed:37/255.0 green:116/255.0 blue:181/255.0 alpha:1];
            getCodeBtn.frame=CGRectMake(0, 10/2.0, 60, btn_h-10);
            getCodeBtn.titleLabel.font=[UIFont systemFontOfSize:10];
            getCodeBtn.layer.borderColor=[UIColor colorWithRed:146/255.0 green:208/255.0 blue:234/255.0 alpha:1].CGColor;
            getCodeBtn.layer.cornerRadius=2.0;
            getCodeBtn.layer.borderWidth=1.0;
            [getCodeBtn setTitle:@"获取验证码" forState:UIControlStateNormal];
            [getCodeBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            [getCodeBtn addTarget:self action:@selector(getCodeBtnClick:) forControlEvents:UIControlEventTouchUpInside];
            [codeBackgroundView addSubview:getCodeBtn];
            phoneTextField.rightView=codeBackgroundView;
            phoneTextField.rightViewMode=UITextFieldViewModeAlways;
            phoneTextField.keyboardType=UIKeyboardTypeNumberPad;
            _getCodeBtn=getCodeBtn;
            _codeTextField=phoneTextField;
        }else if (i==0){
            phoneTextField.keyboardType=UIKeyboardTypeNumberPad;
            NSUserDefaults *user=[NSUserDefaults standardUserDefaults];
            NSString *telephone=[user objectForKey:@"userPhone"];
            phoneTextField.text=telephone;
            _oldPhoneText=phoneTextField;
            //phoneTextField.userInteractionEnabled=NO;
        }else if (i==2){
            phoneTextField.secureTextEntry=YES;
            _userNewPasswordTextField=phoneTextField;
        }
    }
//    //性别
//    UILabel *nameLab=[[UILabel alloc]initWithFrame:CGRectMake(30, 15+(btn_h*2+5)*_dataArray.count, 50, btn_h)];
//    nameLab.text=@"性  别";
//    nameLab.font=[UIFont systemFontOfSize:15];
//    nameLab.textColor=[UIColor blackColor];
//    [_backgroundView addSubview:nameLab];
    
    //确定
    UIButton *registerBtn=[UIButton buttonWithType:UIButtonTypeCustom];
    registerBtn.frame=CGRectMake((self.view.frame.size.width-150)/2.0, 45+(btn_h*2+5)*_dataArray.count, 150, 35);
    registerBtn.backgroundColor=[UIColor colorWithRed:87/255.0 green:187/255.0 blue:215/255.0 alpha:1];
    [registerBtn setTitle:@"确定" forState:UIControlStateNormal];
    registerBtn.titleLabel.font = [UIFont fontWithName:@"Arial-BoldMT" size:20 * kAdjustParamater];
    [registerBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [registerBtn addTarget:self action:@selector(registerBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    registerBtn.layer.borderColor=[UIColor colorWithRed:87/255.0 green:187/255.0 blue:215/255.0 alpha:1].CGColor;
    registerBtn.layer.borderWidth=1.0;
    registerBtn.layer.cornerRadius=5.0;
    [_backgroundView addSubview:registerBtn];
    _sureBtn=registerBtn;
}


#pragma mark 获取验证码
-(void)getCodeBtnClick:(UIButton *)sender
{
   
    
    UITextField *textField=[self.view viewWithTag:100];
    if ([self checkTel:textField.text]) {
        [_oldPhoneText resignFirstResponder];
        [_codeTextField becomeFirstResponder];
        _myTimer=[NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(timerRun) userInfo:nil repeats:YES];
        NSLog(@"获取验证码");
        _getCodeBtn.userInteractionEnabled=NO;
        [self getTelephoneCode];
    }
    
    
}

#pragma mark - 取消界面编辑状态
- (void)cancelEditing:(UITapGestureRecognizer *)tapGes
{
    [self.view endEditing:YES];
}

#pragma mark - textField代理
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [textField resignFirstResponder];
    return YES;
}

#pragma mark 启动定时器
-(void)timerRun
{
    if (_myTime>0) {
        [_getCodeBtn setTitle:[NSString stringWithFormat:@"%ds后获取",_myTime] forState:UIControlStateNormal];
    }else{
        _myTime=60;
        _getCodeBtn.userInteractionEnabled=YES;
        [_myTimer invalidate];
        _myTimer=nil;
        [_getCodeBtn setTitle:[NSString stringWithFormat:@"获取验证码"] forState:UIControlStateNormal];
    }
    _myTime--;
}


#pragma mark 忘记密码/重置密码
-(void)registerBtnClick:(UIButton *)sender
{
#warning 张国文写的，优化逻辑
    // 取消编辑状态
    [_userNewPasswordTextField resignFirstResponder];
    
    //_passwordType  1登录密码  2健康档案密码
    if (_passwordType==1) {
        // 说明是重置密码
//        if ([self checkTel:_oldPhoneText.text]) {
//            
//         //   [self getTelephoneCode];
//        }
        if (![_telephoneCode isEqualToString:_codeTextField.text]) {
            // 验证码不正确
            [self addAleltWithContent:@"验证码输入错误"];
        } else {
            if ([self checkTel:_oldPhoneText.text] && [_telephoneCode isEqualToString:_codeTextField.text] && _userNewPasswordTextField.text.length > 0) {
                if (_userNewPasswordTextField.text.length < 6 || [_userNewPasswordTextField.text containsString:@" "]) {
                    [self addAleltWithContent:@"新密码长度需要大于等于6位且不能包含空格"];
                } else {
                    // 重置密码
                    [self resetLoginPasswword];
                }
            } else {
                [self addAleltWithContent:@"内容不能为空"];
            }
        }
        
    }
    if (_passwordType==2) {
        
    }
}

#warning 张国文写的
#pragma mark - 根据内容提示
- (void)addAleltWithContent:(NSString *)content
{
    UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"提示" message:content preferredStyle:UIAlertControllerStyleAlert];
    // 修改标题颜色
    NSMutableAttributedString *title = [[NSMutableAttributedString alloc] initWithString:@"提示"];
    [title addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(0, 2)];
    [title addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:17] range:NSMakeRange(0, 2)];
    [alertVC setValue:title forKey:@"attributedTitle"];
    UIAlertAction *sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        
    }];
    [alertVC addAction:sureAction];
    [self presentViewController:alertVC animated:YES completion:nil];
}


#pragma mark 判断手机号码的正则表达式
- (BOOL)checkTel:(NSString *)str

{
    
    if ([str length] == 0) {
        
        UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"手机号码不能为空" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
        
        [alert show];
        
        return NO;
        
    }
    
    //1[0-9]{10}
    
    //^((13[0-9])|(15[^4,\\D])|(18[0,5-9]))\\d{8}$
    
    //    NSString *regex = @"[0-9]{11}";
    
    NSString *regex = @"^((13[0-9])|(147)|(15[^4,\\D])|(18[0,5-9]))\\d{8}$";
    
    NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex];
    
    BOOL isMatch = [pred evaluateWithObject:str];
    
    if (!isMatch) {
        
        UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"手机号码格式不正确" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
        
        [alert show];
        return NO;
        
    }
    
    
    
    return YES;
    
}
-(void)viewWillAppear:(BOOL)animated
{
    if (_myTime>0) {
        [_myTimer invalidate];
        _myTimer=nil;
        _myTime=60;
        _getCodeBtn.userInteractionEnabled=YES;
    }
}
//- (void)viewDidLoad {
//    [super viewDidLoad];
//    self.view.backgroundColor=[UIColor whiteColor];
//    [self createNavigationController];
//    [self createUI];
//    // Do any additional setup after loading the view.
//}
//-(void)createNavigationController
//{
//    //返回按钮
//    UIButton *backBtn=[UIButton buttonWithType:UIButtonTypeCustom];
//    backBtn.frame=CGRectMake(0, 0, 20, 20);
//    [backBtn setBackgroundImage:[UIImage imageNamed:@"left_back"] forState:UIControlStateNormal];
//    backBtn.tag=1;
//    [backBtn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
//    self.navigationItem.leftBarButtonItem=[[UIBarButtonItem alloc]initWithCustomView:backBtn];
//    
//    //标题
//    UILabel *lab=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 100, 44)];
//    lab.text=@"忘记密码";
//    lab.textColor=[UIColor whiteColor];
//    lab.font=[UIFont systemFontOfSize:20];
//    lab.textAlignment=NSTextAlignmentCenter;
//    self.navigationItem.titleView=lab;
//    self.navigationController.navigationBar.barTintColor=[UIColor colorWithRed:87/255.0 green:187/255.0 blue:215/255.0 alpha:1];
//}
//#pragma mark 返回上一页
//-(void)btnClick:(UIButton *)sender
//{
//    if (sender.tag==1) {
//        [self.navigationController popViewControllerAnimated:YES];
//
//    }else if(sender.tag==2){
//        [[UIApplication sharedApplication]openURL:[NSURL URLWithString:@"tel://10086"]];
//    }
//}
//-(void)createUI
//{
//    self.navigationController.navigationBar.barTintColor=[UIColor colorWithRed:69/255.0 green:167/255.0 blue:212/255.0 alpha:1];
//    UIButton *btn=[UIButton buttonWithType:UIButtonTypeCustom];
//    btn.backgroundColor=[UIColor colorWithRed:87/255.0 green:187/255.0 blue:215/255.0 alpha:1];
//    btn.bounds=CGRectMake(0, 0, 150, 35);
//    btn.center=self.view.center;
//    btn.tag=2;
//    btn.titleLabel.font=[UIFont systemFontOfSize:15];
//    btn.layer.borderColor=[UIColor colorWithRed:87/255.0 green:187/255.0 blue:215/255.0 alpha:1].CGColor;
//    btn.layer.borderWidth=1.0;
//    btn.layer.cornerRadius=5.0;
//    [btn setTitle:@"联系我们:1008611" forState:UIControlStateNormal];
//    [btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
//    [btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
//    [self.view addSubview:btn];
//}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

//获取登录密码验证码
-(void)getTelephoneCode
{
    AFHTTPRequestOperationManager *manager=[AFHTTPRequestOperationManager manager];
    manager.requestSerializer=[AFHTTPRequestSerializer serializer];
    manager.responseSerializer=[AFHTTPResponseSerializer serializer];
    
//    NSUserDefaults *user=[NSUserDefaults standardUserDefaults];
//    NSString *telephone=[user objectForKey:@"userPhone"];
    
    [manager POST:[NSString stringWithFormat:GetForgetPasswordCode,_oldPhoneText.text] parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSDictionary *dic=[NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers error:nil];
        NSLog(@"登录密码验证码%@",dic);
        if (dic) {
            _telephoneCode=dic[@"code"];
        }
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        NSLog(@"error%@",error.localizedDescription);
    }];
}

//重置登录密码
-(void)resetLoginPasswword
{
//    if ([_telephoneCode isEqualToString:_codeTextField.text]) {
//        if (_userNewPasswordTextField.text.length>0) {
//            AFHTTPRequestOperationManager *manager=[AFHTTPRequestOperationManager manager];
//            manager.requestSerializer=[AFHTTPRequestSerializer serializer];
//            manager.responseSerializer=[AFHTTPResponseSerializer serializer];
//            
//            NSUserDefaults *user=[NSUserDefaults standardUserDefaults];
//            NSString *telephone=[user objectForKey:@"userPhone"];
//            
//            [manager POST:[NSString stringWithFormat:ResetLoginPassword,telephone] parameters:@{@"phone":telephone,@"code":_telephoneCode,@"password":_userNewPasswordTextField.text} success:^(AFHTTPRequestOperation *operation, id responseObject) {
//                [self.view showTiShiMessage:@"修改成功"];
//                NSDictionary *dic=[NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers error:nil];
//                NSLog(@"登录密码%@",dic);
//            } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
//                NSLog(@"error%@",error.localizedDescription);
//            }];
//
//        }else{
//            [self.view showTiShiMessage:@"密码不能为空"];
//            return;
//
//        }
//        
//        
//    }else{
//        [self.view showTiShiMessage:@"验证码错误"];
//        return;
//    }
#warning 张国文写的，优化逻辑
    AFHTTPRequestOperationManager *manager=[AFHTTPRequestOperationManager manager];
    manager.requestSerializer=[AFHTTPRequestSerializer serializer];
    manager.responseSerializer=[AFHTTPResponseSerializer serializer];
    
//    NSUserDefaults *user=[NSUserDefaults standardUserDefaults];
//    NSString *telephone=[user objectForKey:@"userPhone"];
    NSString *telephone = _oldPhoneText.text;
    NSLog(@"手机号:%@", telephone);
    [manager POST:[NSString stringWithFormat:ResetLoginPassword,telephone] parameters:@{@"phone":telephone,@"code":_telephoneCode,@"password":_userNewPasswordTextField.text} success:^(AFHTTPRequestOperation *operation, id responseObject) {
    
        NSDictionary *dic=[NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers error:nil];
        NSDictionary *statusDic = [dic valueForKey:@"status"];
        NSInteger codeCount = [[statusDic valueForKey:@"code"] integerValue];
        if (codeCount == 0) {
            NSLog(@"登录密码%@",dic);
            // 说明修改成功
           // [self.view showTiShiMessage:@"修改成功"];
            dispatch_async(dispatch_get_main_queue(), ^{
                 [[JiaZaiAnimationHandle shareJiaZaiAnimationHandle] addAlertWithAnimationByTitle:@"修改成功" toView:self];
            });
             NSLog(@"登录密码%@",dic);
        } else if (codeCount == 1) {
            NSString *errorString = [statusDic valueForKey:@"msg"];
            if ([errorString isEqualToString:@"The selected phone is invalid."]) {
                // 说明该手机号不存在
                dispatch_async(dispatch_get_main_queue(), ^{
                    [[JiaZaiAnimationHandle shareJiaZaiAnimationHandle] addAlertWithAnimationByTitle:@"您还没有注册，请先注册！" toView:self];
                });
            } else {
                    [self.view showTiShiMessage:@"修改失败，请重试"];
            }
           

        }
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        NSLog(@"error%@",error.localizedDescription);
    }];

}

//获取健康档案面验证码
-(void)getHealthPasswordCode
{
    AFHTTPRequestOperationManager *manager=[AFHTTPRequestOperationManager manager];
    manager.requestSerializer=[AFHTTPRequestSerializer serializer];
    manager.responseSerializer=[AFHTTPResponseSerializer serializer];
    
    NSUserDefaults *user=[NSUserDefaults standardUserDefaults];
    NSString *telephone=[user objectForKey:@"userPhone"];
    NSString *token=[user objectForKey:@"token"];
    
    [manager POST:[NSString stringWithFormat:GetForgetHealthCode,telephone,token] parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSDictionary *dic=[NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers error:nil];
        NSLog(@"健康档案密码验证码%@",dic);
        if (dic) {
            _healthCode=dic[@"code"];
        }
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        NSLog(@"error%@",error.localizedDescription);
    }];

}

@end
